package com.huilang.demo2;

public class Phone {
    private String cpu;
    private String screen;
    private String memory;
    private String maindoard;

    private Phone() {
    }
    private  Phone(Builder builder) {
        this.cpu = builder.cpu;
        this.screen = builder.screen;
        this.memory = builder.memory;
        this.maindoard = builder.maindoard;

    }

    public  static  final class Builder{
        private String cpu;
        private String screen;
        private String memory;
        private String maindoard;

        public Builder setCpu(String cpu) {
            this.cpu = cpu;
            return this;
        }
        public Builder setScreen(String screen) {
            this.screen = screen;
            return this;
        }
        public Builder setMemory(String memory) {
            this.memory = memory;
            return this;
        }
        public Builder setMaindoard(String maindoard) {
            this.maindoard = maindoard;
            return this;
        }
        public Phone build() {
            return new Phone(this);
        }
    }

    @Override
    public String toString() {
        return "Phone{" +
                "cpu='" + cpu + '\'' +
                ", screen='" + screen + '\'' +
                ", memory='" + memory + '\'' +
                ", maindoard='" + maindoard + '\'' +
                '}';
    }
}

class PhoneTest{
    public static void main(String[] args) {
        Phone phone = new Phone.Builder().setScreen("screen").setMemory("memory").setMaindoard("maindoard").build();

        System.out.println(phone);
    }
}
